$('.right-titleicon').on("click",function(e){
	projectVM.showMenulist()
})
		mui.plusReady(function(){
			let pageId = plus.webview;
			 window.addEventListener('reloadPage', function(event) {//A页面自定义事件
				projectVM.page = 1;
				projectVM.getListData();
			 });
		});
		let that;
		projectVM = new Vue({
			el: "#content",
			data: {
				searchType:"todo",
				modifyBy:"",//当前操作人工号
				onlyselect:false,//是否为只读
				keyWord:"",//当前搜索关键字
				onStatus:false,
				showPop:false,
				showMenu:false,
				menuList:[
					{name:'投入',path:'goIn.html'},{name:'退出',path:'goOut.html'},
				],
				filterText:'all', //筛选条件
				list:[],
				page:1,
			},
			created: function() {
				that = this;
				setTimeout(that.getListData,500);
			},
			methods: {
				searchDevice(e){
					that.page = 1;
					that.getListData()
				},
				//获取列表数据
				getListData(){
					let config = mui.neioConfig.getNeioConfig();
					let url = config.URL.queryPlateOperate;
					let persionData = JSON.parse(localStorage.getItem("neiosUser"));
					that.modifyBy = persionData.userId;//获取当前登录人id
					let param = {};
					param.pageSize = "10";
					param.pageIndex = that.page;
					param.areaCompanyCode = persionData.companyNewCode;
					param.stationCode = persionData.stationNewCode;
					param.role = persionData.roles;
					param.keyWord = that.keyWord;
					param.searchType = "0";
					that.doNetWork(url,param)
				},
				//开始网络请求
				doNetWork(url,param){
					console.log("参数:"+JSON.stringify(param))
					mui.neiosRequst.httpRequst(url,param,function(ret){
						console.log(JSON.stringify(ret))
						that.hideOperBtn();
						if(ret.code == 0){
							if(ret.code == 0){
								if(that.page == 1){
									mui('#scroll').pullRefresh().enablePullupToRefresh();
									mui('#scroll').pullRefresh().endPullupToRefresh();
									that.list = ret.data.records
								}else{
									mui('#scroll').pullRefresh().endPullupToRefresh();
									that.list = that.list.concat(ret.data.records)
								}
								
								if(ret.data.current >= ret.data.pages){
									console.log("====================禁用====================") 
									mui('#scroll').pullRefresh().disablePullupToRefresh();
									mui('#scroll').pullRefresh().endPullupToRefresh(true);
								}
							}
						}
						if( ret.code == 1){
							mui.toast(ret.msg)
						}
					},function(err){
						console.log("失败回掉："+JSON.stringify(err))
					})
				},
				//删除操作
				itemDelete(item){
					this.hideOperBtn()
					mui.confirm('是否删除','提示',['取消','确认'],function (e) {
						if(1 == e.index){
							let datas = mui.neioConfig.getDevoice(item,0,1,that);
							//重命名KEY
							let plateOperate = datas.netDeviceOperate;
							let infoListParam = datas.netDeviceInfo;
							//重新存入字段
							datas.plateOperate = plateOperate;
							datas.infoListParam = infoListParam;
							
							datas.plateOperate.dataStatus = "1";
							//移除错误的参数
							datas.netDeviceOperate = undefined;
							datas.netDeviceInfo = undefined;
							
							let config = mui.neioConfig.getNeioConfig();
							let url = config.URL.saveOrUpdatePlateOperate;

							mui.neiosRequst.httpRequst(url,datas,function(ret){
								if(ret.code == 0){
									that.page = 1;
									mui.toast(ret.msg)
									that.getListData("");
								}
								if( ret.code == 1){
									mui.toast(ret.msg)
								}
							},function(err){
								console.log("失败回掉："+JSON.stringify(err))
							})
						}
					},'div')
					
				},
				//组装数据
				createData(param){
					let array = [];
					array.push(param)
					let manTab = paramJson.getEditObj(array,1,1,"21","in",that)
					let dataObj = paramJson.getInfoList(array,manTab,"in")
				},
				
				//编辑数据
				saveEditParam(item){
					console.log(JSON.stringify(item))
					this.hideOperBtn()
					if(item.outOperateId != null && item.outStatus != "90"){
						let config = mui.neioConfig.getNeioConfig();
						let key = config.KEYS.PLATENDATA;
						mui.neioConfig.setStorage(key,JSON.stringify(item));
						that.navTo('editOut.html');
					}
					if(item.inOperateId != null && item.inStatus != "90"){
						let config = mui.neioConfig.getNeioConfig();
						let key = config.KEYS.PLATENDATA;
						mui.neioConfig.setStorage(key,JSON.stringify(item));
						that.navTo('editIn.html');
					}

				},
				//存入详情页需要的参数
				saveDetailParam(item){
					this.hideOperBtn()
					let config = mui.neioConfig.getNeioConfig();
					let key = config.KEYS.PLATENDATA;
					mui.neioConfig.setStorage(key,JSON.stringify(item));
					that.navTo('detail.html');
				},
				clickStop(){

				},
				navTo(e){
					this.showMenu = false;
					mui.openWindow({
            			url: e,
            			id: e,
						extras: {},
					waiting: {
						autoShow: false
					}
        			});
				},
				//点击菜单
				menuClick(e){
					this.showMenu = false;
					if(e.name == '我值班'){
						this.onStatus? this.onStatus= false : this.onStatus=true
					}
					else{
						this.navTo(e.path)
					}
				},
				//左上角菜单显示隐藏
				showMenulist(){
					this.showMenu?this.showMenu=false:this.showMenu=true
				},
				//切换筛选条件
				changeFliter(e){
					this.filterText = e
				},
				showPop(){
					this.show_popup = true
				},
				hidePopup(){
					this.show_popup = false	
				},
				//获取格式化后的时间
				getTime(timer){
					let times = mui.neiosCommon.transTime(new Date(timer),'min')
					return times;
				},
				hideOperBtn () {
					$('.todo').css('width','0');
					$('.toAppoint').css('width','0');
				},
				
			}
			
			})

		// 显示操作按钮
		function showOperBtn (el) {
			$('.todo').css('width','0');
			$(el).next().css('width','39vw');
		}

	mui.init({
      pullRefresh: {
        container: "#scroll", //待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
        down: { //下拉刷新
		  style: 'circle',
          height: 50, //可选,默认50.触发下拉刷新拖动距离,
          auto: false, //可选,默认false.首次加载自动下拉刷新一次
          contentdown: "下拉可以刷新", //可选，在下拉可刷新状态时，下拉刷新控件上显示的标题内容
          contentover: "释放立即刷新", //可选，在释放可刷新状态时，下拉刷新控件上显示的标题内容
          contentrefresh: "正在刷新...", //可选，正在刷新状态时，下拉刷新控件上显示的标题内容
          callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
            projectVM.page = 1;
			projectVM.keyWord = "";
            projectVM.getListData("");
            ////没有更多内容了，endPulldown 传入true， 不再执行下拉刷新
			mui('#scroll').pullRefresh().endPulldownToRefresh();
			mui('#scroll').pullRefresh().enablePullupToRefresh();
			mui('#scroll').pullRefresh().endPullupToRefresh(true); 
        }
        },
        up: { //上拉加载
          height: 50, //可选.默认50.触发上拉加载拖动距离
          auto: false, //可选,默认false.自动上拉加载一次
          contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
          contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
          callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
			projectVM.page = projectVM.page + 1;
            projectVM.getListData("");
          }
        }
      },
    });